Refactor BmpTool into a dedicated API layer and expose manipulation f…#10
Merged
JacobBorden merged 2 commits intodevelopmentfrom May 31, 2025
Merged
Refactor BmpTool into a dedicated API layer and expose manipulation f…#10JacobBorden merged 2 commits intodevelopmentfrom
JacobBorden merged 2 commits intodevelopmentfrom
Conversation
…unctions. This commit significantly refactors the BmpTool to act as a true API layer over the core bitmap processing logic. Key changes: - Modified `BmpTool::load` and `BmpTool::save` in `src/format/bitmap.cpp` to delegate more responsibility to the core library functions (::CreateMatrixFromBitmap, ::CreateBitmapFromMatrix), reducing redundant parsing and serialization logic. - Removed unused internal formatting helpers from `src/format/`. - Exposed 24 image manipulation functions (shrink, rotate, greyscale, color adjustments, blur, etc.) through the `BmpTool` API in `include/bitmap.hpp`. These functions now operate on `BmpTool::Bitmap` and return `BmpTool::Result`. - Implemented these API functions in `src/format/bitmap.cpp`, where they wrap calls to the core library, handling data conversion (RGBA for API, BGRA for internal matrix) and error propagation. - Updated `main.cpp` to exclusively use the `BmpTool` API for all bitmap operations, serving as an example of API usage. - Created `tests/test_bmptool_api_manipulations.cpp` with unit tests for the newly exposed `BmpTool` image manipulation functions. - Existing tests for core components (`test_bitmap.cpp`, `test_bitmap_file.cpp`) and relevant fuzz tests (`fuzz_bitmap.cpp`, `fuzz_bmp_tool_save.cpp`) were reviewed and confirmed/kept. This refactoring provides a cleaner separation of concerns, with BmpTool now providing a consistent interface for all bitmap operations.
…u'd like me to use, or are you asking me to do something with this information?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…unctions.
This commit significantly refactors the BmpTool to act as a true API layer over the core bitmap processing logic.
Key changes:
BmpTool::loadandBmpTool::saveinsrc/format/bitmap.cppto delegate more responsibility to the core library functions (::CreateMatrixFromBitmap, ::CreateBitmapFromMatrix), reducing redundant parsing and serialization logic.src/format/.BmpToolAPI ininclude/bitmap.hpp. These functions now operate onBmpTool::Bitmapand returnBmpTool::Result.src/format/bitmap.cpp, where they wrap calls to the core library, handling data conversion (RGBA for API, BGRA for internal matrix) and error propagation.main.cppto exclusively use theBmpToolAPI for all bitmap operations, serving as an example of API usage.tests/test_bmptool_api_manipulations.cppwith unit tests for the newly exposedBmpToolimage manipulation functions.test_bitmap.cpp,test_bitmap_file.cpp) and relevant fuzz tests (fuzz_bitmap.cpp,fuzz_bmp_tool_save.cpp) were reviewed and confirmed/kept.This refactoring provides a cleaner separation of concerns, with BmpTool now providing a consistent interface for all bitmap operations.